package com.tptech.nearme.helper;

import java.io.IOException;
import java.util.Arrays;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.tptech.nearme.model.Location;

public class GeocodeResponse {

	
	private STATUS status;
	private String formattedAddress;
	private Double lat,lon;
	
	private ACCURACY accuracy;
	private String locality;
	private String sublocality;
	private String postalCode;
	private String countryCode;
	private boolean partial;
	


	public enum ACCURACY{
		ROOFTOP,
		RANGE_INTERPOLATED,
		GEOMETRIC_CENTER,
		APPROXIMATE
	};

	public enum STATUS{
		OK,
		ZERO_RESULTS,
		OVER_QUERY_LIMIT,
		REQUEST_DENIED,
		INVALID_REQUEST,
		UNKNOWN_ERROR
	}

	public Location getLocation(){
		Location l = new Location();

		l.setPostalCode(this.postalCode.toLowerCase());
		l.setLocality(this.locality.toLowerCase());
		l.setSublocality(this.sublocality.toLowerCase());
		l.setCountry(this.countryCode.toLowerCase());
		return l;
	}
	
	public String getSublocality() {
		return sublocality;
	}
	public void setSublocality(String sublocality) {
		this.sublocality = sublocality;
	}
	
	public STATUS getStatus() {
		return status;
	}

	public void setStatus(STATUS status) {
		this.status = status;
	}

	public String getFormattedAddress() {
		return formattedAddress;
	}

	public void setFormattedAddress(String formattedAddress) {
		this.formattedAddress = formattedAddress;
	}

	public Double getLat() {
		return lat;
	}

	public void setLat(Double lat) {
		this.lat = lat;
	}

	public Double getLon() {
		return lon;
	}

	public void setLon(Double lon) {
		this.lon = lon;
	}

	public ACCURACY getAccuracy() {
		return accuracy;
	}

	public void setAccuracy(ACCURACY accuracy) {
		this.accuracy = accuracy;
	}

	public String getPostalCode() {
		return postalCode;
	}
	public void setPostalCode(String postalCode) {
		this.postalCode = postalCode;
	}
	public String getLocality() {
		return locality;
	}

	public void setLocality(String locality) {
		this.locality = locality;
	}
	
	public boolean isPartial() {
		return partial;
	}

	public void setPartial(boolean partial) {
		this.partial = partial;
	} ;
	
	public String getCountryCode() {
		return countryCode;
	}

	public void setCountryCode(String countryCode) {
		this.countryCode = countryCode;
	}

	@Override
	public String toString() {
		return getFormattedAddress();
	}
	
}
